/**
 * Copyright (c) 2008 Trent Hoeppner
 * 
 * This file is part of BillCalc.
 * 
 * BillCalc is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * BillCalc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with BillCalc.  If not, see <http://www.gnu.org/licenses/>.
 **/

package com.trentech.billcalc.event;

import java.util.Date;

import com.trentech.billcalc.FinanceManager;

/**
 * StartVacationEvent is used to notify that a Resident has gone on vacation,
 * and need not pay for bills that vary with usage.
 * 
 * @author Trent Hoeppner
 */
public class StartVacationEvent extends Event {

    /**
     * Constructor for StartVacationEvent.
     * 
     * @param   date            the first day the resident was not in the 
     *                          apartment.  Cannot be null.
     * @param   residentName    the name of the resident who is going on 
     *                          vacation.  Cannot be null or empty.
     */
    public StartVacationEvent(Date date, String residentName) {
        super(date, residentName);
    }
    

    /**
     * {@inheritDoc}
     */
    public void process(FinanceManager manager) {
        manager.vacationStarts(getDate(), getName());
    }


    /**
     * {@inheritDoc}
     */
    public void validate(String propertyName, FinanceManager manager) 
        throws InvalidResultException {
    
        super.validate(propertyName, manager);
        if (propertyName.equals("name")) {
            resident(propertyName, getName(), manager);
        }
    }
}
